package com.ihr360.oneclick.dto.spreadsheet;

import com.ihr360.commons.model.entity.StringIdWithTime;
import com.ihr360.hibernate.type.encrypt.JsonEncryptType;
import com.ihr360.oneclick.entity.NotifyStateType;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
 * 电子表格 行数据
 */
@Table(name = "tab_spreadsheet_row")
@Entity
@DynamicUpdate
@TypeDefs({
        @TypeDef(name = "json-encrypt", typeClass = JsonEncryptType.class)
})
public class SpreadsheetRowDto extends StringIdWithTime {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "spreadsheetId")
    private SpreadsheetDto spreadsheet;

    /**
     * 员工名录Id
     */
    @Column(length = 40)
    private String staffRecordId;

    @Column(length = 40, nullable = false)
    private String termId;

    @Column(length = 40, nullable = false)
    private String companyId;

    /**
     * 所属月份
     */
    @Column(nullable = false)
    private Date month;

    /**
     * 手机号码
     */
    @Column(length = 40, nullable = false)
    private String mobileNo;

    /**
     * 姓名
     */
    @Column(length = 40, nullable = false)
    private String userName;

    /**
     * 邮箱
     */
    @Column
    private String email;

    /**
     * 发布状态
     */
    @Column
    private Boolean publishStatus;

    /**
     * 固定字段1 姓名
     */
    @Column(length = 40)
    private String fixedColumn1;

    /**
     * 固定字段2 手机
     */
    @Column(length = 40)
    private String fixedColumn2;

    /**
     * 固定字段3
     */
    @Column(length = 40)
    private String fixedColumn3;

    /**
     * 固定字段4
     */
    @Column(length = 40)
    private String fixedColumn4;

    /**
     * 固定字段5
     */
    @Column(length = 100)
    private String fixedColumn5;


    /**
     * 固定字段6
     */
    @Column(length = 100)
    private String fixedColumn6;

    /**
     * 固定字段7
     */
    @Column(length = 100)
    private String fixedColumn7;

    /**
     * 固定字段8
     */
    @Column(length = 100)
    private String fixedColumn8;

    /**
     * 固定字段9
     */
    @Column(length = 200)
    private String fixedColumn9;

    /**
     * 固定字段10
     */
    @Column(length = 200)
    private String fixedColumn10;

    /**
     * 固定字段12
     * 是否允许发布
     */
    @Column
    private Boolean fixedColumn11;

    /**
     * 行号
     */
    @Column
    private int rowIndex;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "row_header_id")
    private SpreadSheetRowHeaderDto rowHeader;

    /**
     * blob，二进制形式的长文本数据,BLOB类型 最大65535=64k
     * 这里面放了行内的所有数据，数据通过序列化后存入
     */
    @Type(type = "json-encrypt")
    @Column(columnDefinition = "text")
    //private byte[] data;
    private List<Object> data;

    /**
     * 微信通知状态
     */
    @Column
    @Enumerated(EnumType.STRING)
    private NotifyStateType weChatNoticeStatus = NotifyStateType.NOT_SEND;

    /**
     * 短信通知状态
     */
    @Column
    @Enumerated(EnumType.STRING)
    private NotifyStateType smsNoticeStatus = NotifyStateType.NOT_SEND;

    /**
     * 邮件通知状态
     */
    @Column
    @Enumerated(EnumType.STRING)
    private NotifyStateType mailNoticeStatus =  NotifyStateType.NOT_SEND;

    @Column
    private Boolean isRead = false;

    public SpreadsheetRowDto() {
    }


    public NotifyStateType getWeChatNoticeStatus() {
        return weChatNoticeStatus;
    }

    public void setWeChatNoticeStatus(NotifyStateType weChatNoticeStatus) {
        this.weChatNoticeStatus = weChatNoticeStatus;
    }

    public NotifyStateType getSmsNoticeStatus() {
        return smsNoticeStatus;
    }

    public void setSmsNoticeStatus(NotifyStateType smsNoticeStatus) {
        this.smsNoticeStatus = smsNoticeStatus;
    }

    public NotifyStateType getMailNoticeStatus() {
        return mailNoticeStatus;
    }

    public void setMailNoticeStatus(NotifyStateType mailNoticeStatus) {
        this.mailNoticeStatus = mailNoticeStatus;
    }

    public SpreadsheetDto getSpreadsheet() {
        return spreadsheet;
    }

    public void setSpreadsheet(SpreadsheetDto spreadsheet) {
        this.spreadsheet = spreadsheet;
    }

    public String getStaffRecordId() {
        return staffRecordId;
    }

    public void setStaffRecordId(String staffRecordId) {
        this.staffRecordId = staffRecordId;
    }

    public String getTermId() {
        return termId;
    }

    public void setTermId(String termId) {
        this.termId = termId;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getFixedColumn1() {
        return fixedColumn1;
    }

    public void setFixedColumn1(String fixedColumn1) {
        this.fixedColumn1 = fixedColumn1;
    }

    public String getFixedColumn2() {
        return fixedColumn2;
    }

    public void setFixedColumn2(String fixedColumn2) {
        this.fixedColumn2 = fixedColumn2;
    }

    public String getFixedColumn3() {
        return fixedColumn3;
    }

    public void setFixedColumn3(String fixedColumn3) {
        this.fixedColumn3 = fixedColumn3;
    }

    public String getFixedColumn4() {
        return fixedColumn4;
    }

    public void setFixedColumn4(String fixedColumn4) {
        this.fixedColumn4 = fixedColumn4;
    }

    public String getFixedColumn5() {
        return fixedColumn5;
    }

    public void setFixedColumn5(String fixedColumn5) {
        this.fixedColumn5 = fixedColumn5;
    }

    public String getFixedColumn6() {
        return fixedColumn6;
    }

    public void setFixedColumn6(String fixedColumn6) {
        this.fixedColumn6 = fixedColumn6;
    }

    public String getFixedColumn7() {
        return fixedColumn7;
    }

    public void setFixedColumn7(String fixedColumn7) {
        this.fixedColumn7 = fixedColumn7;
    }

    public String getFixedColumn8() {
        return fixedColumn8;
    }

    public void setFixedColumn8(String fixedColumn8) {
        this.fixedColumn8 = fixedColumn8;
    }

    public String getFixedColumn9() {
        return fixedColumn9;
    }

    public void setFixedColumn9(String fixedColumn9) {
        this.fixedColumn9 = fixedColumn9;
    }

    public String getFixedColumn10() {
        return fixedColumn10;
    }

    public void setFixedColumn10(String fixedColumn10) {
        this.fixedColumn10 = fixedColumn10;
    }

    public int getRowIndex() {
        return rowIndex;
    }

    public void setRowIndex(int rowIndex) {
        this.rowIndex = rowIndex;
    }

    public SpreadSheetRowHeaderDto getRowHeader() {
        return rowHeader;
    }

    public void setRowHeader(SpreadSheetRowHeaderDto rowHeader) {
        this.rowHeader = rowHeader;
    }

    public Boolean getPublishStatus() {
        return publishStatus;
    }

    public void setPublishStatus(Boolean publishStatus) {
        this.publishStatus = publishStatus;
    }

    public Boolean getFixedColumn11() {
        return fixedColumn11;
    }

    public void setFixedColumn11(Boolean fixedColumn12) {
        this.fixedColumn11 = fixedColumn12;
    }

    //    public byte[] getData() { return data; }
//
//    public void setData(byte[] data) { this.data = data; }
//
//    public String getDataStr() { return new String(data, StandardCharsets.UTF_8); }
//
//    public void setDataStr(String data) { this.data = data.getBytes(); }
//
    public List<Object> getData() {
        return data;
    }

    public void setData(List<Object> data) {
        this.data = data;
    }

    public Date getMonth() {
        return month;
    }

    public void setMonth(Date month) {
        this.month = month;
    }

    public String getMobileNo() {
        return mobileNo;
    }

    public void setMobileNo(String mobileNo) {
        this.mobileNo = mobileNo;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Boolean getRead() {
        return isRead;
    }

    public void setRead(Boolean read) {
        isRead = read;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}